from django.http import JsonResponse
import typing as t

def success_api(message:str = '成功',code:int = 200,data=None):
    return JsonResponse({'success': True, 'message': message, 'code': code,'data':data})

def failure_api(message:str = '失败',code:int = 400):
    return JsonResponse({'success': False, 'message': message, 'code': code})

def table_api(success:bool = True,message:str = "",code:int = 0,total:int = 0,result:t.Union[dict,list] = None):
    return JsonResponse({'success': success, 'message': message, 'code': code, 'total': total,'result': result})
